﻿using System.Collections.Generic;
using UnityEngine;

namespace AI.Graph {


    [AddComponentMenu ("AI/AI Path", 10)]
    [DisallowMultipleComponent]
    public class AIPath : MonoBehaviour {

        [SerializeField]
        private List<Vector3> m_points = new List<Vector3> ();

        [SerializeField]
        private bool m_isPathClosed = false;

        public bool isPathClosed {
            get { return m_isPathClosed; }
        }

        public Vector3 this [int i] {
            get { return m_points[i]; }
        }

        public Vector3[] points {
            get { return m_points.ToArray (); }
        }

        public int numPoints {
            get { return m_points.Count; }
        }


        public void AddPoint (Vector3 point) {
            m_points.Add (point);
        }


        public void AddPoint (Vector3 point, int index) {
            m_points.Insert (index % numPoints, point);
        }


        public void RemovePoint (int i) {
            m_points.RemoveAt (i);
        }


        public void RemoveAllPoints () {
            m_points.RemoveRange (0, numPoints);
        }


        public void MovePoint (int i, Vector3 pos) {
            m_points[i] = pos;
        }


        public void Reverse () {
            m_points.Reverse ();
        }

    }


}